<?php

// use Illuminate\Support\Facades\Schema;
use Jialeo\LaravelSchemaExtend\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class InitAgentRecords extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // 
        Schema::create('agent_records', function (Blueprint $table) {

            $table->comment = '分销记录表';

            $table->increments('id');
            $table->uuid('uuid')->index();

            $table->integer('user_id')->index(); // 用户id

            $table->integer('order_id')->index()->nullable()->comment('订单id'); // 用户id
            $table->integer('order_sku_id')->index()->nullable()->comment('订单sku id'); // 用户id

            $table->integer('agent_id')->index()->nullable()->comment('一级代理id'); // 一级代理id
            $table->integer('brokerage_money')->unsigned()->nullable()->comment('一级代理佣金（人民币)'); // 一级代理佣金
            $table->integer('brokerage_score')->unsigned()->nullable()->comment('一级代理佣金(积分)'); // 一级代理佣金

            $table->integer('second_agent_id')->index()->nullable()->comment('二级代理'); // 二级代理
            $table->integer('second_brokerage_money')->unsigned()->nullable()->comment('二级代理佣金人民币'); // 二级代理佣金
            $table->integer('second_brokerage_score')->unsigned()->nullable()->comment('二级代理佣金积分'); // 二级代理佣金

            $table->tinyInteger('status')->unsigned()->default(0)->index()->comment('0待订单完成, 1已发放收益  2为订单取消'); //

            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('agent_records');
    }
}
